# Maintainer: crapStone <crapstone01@gmail.com>
pkgname=rbw
pkgver=1.9.0
pkgrel=0
pkgdesc="Unofficial command line client for Bitwarden."
url="https://git.tozt.net/rbw"
arch="all !s390x !riscv64 !ppc64le" # ring
license="MIT"
depends="pinentry"
makedepends="rust cargo cargo-auditable"
subpackages="
	$pkgname-bash-completion
	$pkgname-fish-completion
	$pkgname-zsh-completion
	"
source="https://git.tozt.net/rbw/snapshot/rbw-$pkgver.tar.gz"
export CARGO_HOME="$srcdir"/cargo


prepare() {
	default_prepare
	cargo fetch --target="$CTARGET" --locked
}

build() {
	cargo auditable build --frozen --release

	target/release/rbw gen-completions bash > rbw.bash
	target/release/rbw gen-completions fish > rbw.fish
	target/release/rbw gen-completions zsh > _rbw
}

check() {
	cargo test --frozen
}

package() {
	install -Dm755 target/release/rbw "$pkgdir"/usr/bin/rbw
	install -Dm755 target/release/rbw-agent "$pkgdir"/usr/bin/rbw-agent

	install -Dm644 rbw.bash \
		"$pkgdir"/usr/share/bash-completion/completions/rbw
	install -Dm644 rbw.fish \
		"$pkgdir"/usr/share/fish/vendor_completions.d/rbw.fish
	install -Dm644 _rbw \
		"$pkgdir"/usr/share/zsh/site-functions/_rbw
}

sha512sums="
1ebe9837574b51e32c645b26c0c47f11fbcf1893adf76ada7b56e3d0b18271594f6047ba5f9acf9aa4d4ff970ad999b42febb070ec687766c035cc5a39748f8b  rbw-1.9.0.tar.gz
"
